# Python 2.6.4
# Project Euler, Problem 94
# Copyright 2010 Talha Zaman

def area(a, b):
    from math import sqrt
    area = sqrt((3*a+b)*(a-b))
    if (a+b)%4:
        return area%2==0
    else:
        return area==int(area)
from time import clock
start = clock()
perim = 0
i = 3
while i<=333333333:
    if area(i, 1):
        print i, i, i+1
        perim += 3*i-1
        i *= 3
    elif area(i, -1):
        print i, i, i-1
        perim += 3*i+1
        i *= 3
    i += 2
stop = clock()
print perim
print stop-start
